package rocket.test;

import java.util.Date;
import java.util.Random;

import rocket.calendar.Visit;
import rocket.medical.Treatment;
import rocket.users.Bill;
import rocket.users.Trainer;
import rocket.users.User;

/**
 * @author justin
 * @version
 * creates random sh*t for testing purposes
 */
public class RandomFactory {

	private static Random rand = new Random();

	/**
	 * @return
	 * creates a user Bill with random attributes
	 */
	@SuppressWarnings("deprecation")
	public static User getBill() {
		String birthDate = "";
		long time = (1000000000000L + Long.parseLong("" + rand.nextInt(10000000)
				+ "" + rand.nextInt(10000000)));
		Date d = new Date(time);
		birthDate += d.getYear();
		while (birthDate.length() < 4)
			birthDate = "0" + birthDate;
		birthDate += d.getMonth();
		while (birthDate.length() < 6)
			birthDate = birthDate.substring(0, 4) + "0"
					+ birthDate.substring(4);
		birthDate += d.getDay();
		while (birthDate.length() < 8)
			birthDate = birthDate.substring(0, 6) + "0"
					+ birthDate.substring(6);

		String city = "";
		for (int i = 0; i < 10; i++) {
			city += "" + (char) (rand.nextInt(26) + 'a');
		}

		String gender = (rand.nextBoolean()) ? "M" : "F";

		String insurance = "";
		for (int i = 0; i < 20; i++) {
			insurance += "" + (char) (rand.nextInt(26) + 'a');
		}

		String name = "";
		for (int i = 0; i < 6; i++) {
			name += "" + (char) (rand.nextInt(26) + 'a');
		}

		String pharmacy = "";
		for (int i = 0; i < 20; i++) {
			pharmacy += "" + (char) (rand.nextInt(26) + 'a');
		}

		String phone = "";
		for (int i = 0; i < 10; i++) {
			phone += rand.nextInt(10);
		}

		String region = "";
		for (int i = 0; i < 10; i++) {
			region += "" + (char) (rand.nextInt(26) + 'a');
		}

		User user = new Bill(0, birthDate, city, gender, insurance, name,
				pharmacy, phone, region, null);
		return user;
	}
	
	@SuppressWarnings("deprecation")
	public static User getTrainer() {
		String birthDate = "";
		long time = (1000000000000L + Long.parseLong("" + rand.nextInt(10000000)
				+ "" + rand.nextInt(10000000)));
		Date d = new Date(time);
		birthDate += d.getYear();
		while (birthDate.length() < 4)
			birthDate = "0" + birthDate;
		birthDate += d.getMonth();
		while (birthDate.length() < 6)
			birthDate = birthDate.substring(0, 4) + "0"
					+ birthDate.substring(4);
		birthDate += d.getDay();
		while (birthDate.length() < 8)
			birthDate = birthDate.substring(0, 6) + "0"
					+ birthDate.substring(6);

		String city = "";
		for (int i = 0; i < 10; i++) {
			city += "" + (char) (rand.nextInt(26) + 'a');
		}

		String gender = (rand.nextBoolean()) ? "M" : "F";

		String insurance = "";
		for (int i = 0; i < 20; i++) {
			insurance += "" + (char) (rand.nextInt(26) + 'a');
		}

		String name = "";
		for (int i = 0; i < 6; i++) {
			name += "" + (char) (rand.nextInt(26) + 'a');
		}

		String pharmacy = "";
		for (int i = 0; i < 20; i++) {
			pharmacy += "" + (char) (rand.nextInt(26) + 'a');
		}

		String phone = "";
		for (int i = 0; i < 10; i++) {
			phone += rand.nextInt(10);
		}

		String region = "";
		for (int i = 0; i < 10; i++) {
			region += "" + (char) (rand.nextInt(26) + 'a');
		}

		User user = new Trainer(0, birthDate, city, gender, insurance, name,
				pharmacy, phone, region, null);
		return user;
	}

	@SuppressWarnings("deprecation")
	/**
	 * @return
	 * creates a Visit with random attributes
	 */
	public static Visit getVisit() {
		long id = 0;
		long userID = rand.nextInt(25) + 1000;
		long professorID = rand.nextInt(25) + 1000;
		long nurseID = rand.nextInt(25) + 1000;
		long treatmentID = rand.nextInt(25) + 1000;
		
		long time = (1000000000000L + Long.parseLong("" + rand.nextInt(10000000)
				+ "" + rand.nextInt(10000000)));
		
		String visitTime = "";
		Date d = new Date(time);
		visitTime += d.getYear();
		while (visitTime.length() < 4)
			visitTime = "0" + visitTime;
		visitTime += d.getMonth();
		while (visitTime.length() < 6)
			visitTime = visitTime.substring(0, 4) + "0"
					+ visitTime.substring(4);
		visitTime += d.getDay();
		while (visitTime.length() < 8)
			visitTime = visitTime.substring(0, 6) + "0"
					+ visitTime.substring(6);
		visitTime += d.getHours();
		while (visitTime.length() < 10)
			visitTime = visitTime.substring(0, 8) + "0"
					+ visitTime.substring(8);
		visitTime += d.getMinutes();
		while (visitTime.length() < 12)
			visitTime = visitTime.substring(0, 10) + "0"
					+ visitTime.substring(10);
		visitTime += d.getSeconds();
		while (visitTime.length() < 14)
			visitTime = visitTime.substring(0, 12) + "0"
					+ visitTime.substring(12);
		
		String visitLocation = "";
		for (int i = 0; i < 10; i++) {
			visitLocation += "" + (char) (rand.nextInt(26) + 'a');
		}
		
		Visit v = new Visit(id, userID, professorID, nurseID, treatmentID, visitTime, visitLocation);
		return v;
	}

	/**
	 * @return
	 * creates a treatment class with random attributes
	 */
	public static Treatment getTreatment(){
		long id = 0;
		long userID = rand.nextInt(25) + 1000;
		long professorID = rand.nextInt(25) + 1000;
		long nurseID = rand.nextInt(25) + 1000;
		long treatmentID = rand.nextInt(25) + 1000;
		long visitID = rand.nextInt(25) + 1000;
		long pokemonID = rand.nextInt(25) + 1000;
		
		long time = (1000000000000L + Long.parseLong("" + rand.nextInt(10000000)
				+ "" + rand.nextInt(10000000)));
		String visitTime = "";
		Date d = new Date(time);
		visitTime += d.getYear();
		while (visitTime.length() < 4)
			visitTime = "0" + visitTime;
		visitTime += d.getMonth();
		while (visitTime.length() < 6)
			visitTime = visitTime.substring(0, 4) + "0"
					+ visitTime.substring(4);
		visitTime += d.getDay();
		while (visitTime.length() < 8)
			visitTime = visitTime.substring(0, 6) + "0"
					+ visitTime.substring(6);
		visitTime += d.getHours();
		while (visitTime.length() < 10)
			visitTime = visitTime.substring(0, 8) + "0"
					+ visitTime.substring(8);
		visitTime += d.getMinutes();
		while (visitTime.length() < 12)
			visitTime = visitTime.substring(0, 10) + "0"
					+ visitTime.substring(10);
		visitTime += d.getSeconds();
		while (visitTime.length() < 14)
			visitTime = visitTime.substring(0, 12) + "0"
					+ visitTime.substring(12);
		
		String orders = "";
		for (int i = 0; i < 20; i++) {
			orders += "" + (char) (rand.nextInt(26) + 'a');
		}
		String symptoms = "";
		for (int i = 0; i < 20; i++) {
			symptoms += "" + (char) (rand.nextInt(26) + 'a');
		}
		String vitals = "";
		for (int i = 0; i < 20; i++) {
			vitals += "" + (char) (rand.nextInt(26) + 'a');
		}
		String diagnosis = "";
		for (int i = 0; i < 20; i++) {
			diagnosis += "" + (char) (rand.nextInt(26) + 'a');
		}
		
		return new Treatment(id,userID,professorID,nurseID,visitID,pokemonID,
				visitTime,orders,symptoms,vitals,diagnosis, null);
		
	}

	public String toString(){
		return "Factory";
	}
	
}
